package Test;
import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        GirlFriend gf = new GirlFriend();


        while (true) {
            try {
                System.out.println("请输入姓名:");
                String name1 = sc.nextLine();
                gf.setName(name1);
                System.out.println("请输入年龄");
                String age1 = sc.nextLine();
                int age = Integer.parseInt(age1);
                gf.setAge(age);
                break;
            } catch (NumberFormatException e) {
                System.out.println("年龄输入格式有误");
                continue;
            } catch (RuntimeException e) {
                System.out.println("姓名长度或年龄大小有误");
                continue;
            }
        }
    }


    }
